<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean" prefix="bean"%>
<%@ taglib uri="/WEB-INF/tld/struts-html" prefix="html"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic" prefix="logic"%>
<%@ taglib uri="/WEB-INF/tld/jstl/c" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/jstl/fn" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="ebb365,ebb365,ebb365">
	<meta http-equiv="description" content="ebb365">
	<title>广告列表管理</title>
	<link rel="stylesheet" type="text/css" href="/admin/css/css.css"></link>
	<script type='text/javascript' src='/dwr/interface/homeSiteDWRServ.js'></script>
		<script type='text/javascript' src='/dwr/engine.js'></script>
		<script type='text/javascript' src='/dwr/util.js'></script> 
	<style type="text/css">
	<!--
	.STYLE1 {font-size: 12px}
	-->
	</style>
	<script language="JavaScript">
<!--//	
		function checkSearch(){
			var f = document.forms[0];
			if(f.title.value==''){
			     return false;
			}
			return true;
		}

		function topage(){
			var page = document.getElementById('toPageId').value;
			if(page!='' && !isNaN(page)){
				var link = document.getElementById('link').value;
				var linkStr = "/admin/banner/homeSiteAdBanner.do?action=search"+link + "&page="+page;
				window.location=encodeURI(linkStr);
				return true;
			}else{
				alert('请输入数字！');
				document.getElementById('toPageId').value='';
				return false;
			}
				return false;
		}

		
		function selectAll(choice) {
			var chk = document.getElementsByName("checkboxparam");
			for (var i=0;i<chk.length;i++) {
				var e=chk[i];
				if(choice==1){
					e.checked=true;
				}
				if(choice==2){
					e.checked=(e.checked?false:true);
				}
				if(choice==3){
					e.checked=false;
				}
			}
		}

		function checkboxIsSelected(){
			var str = new Array();
			var flag = 0;
			var j = 0;
			
			var chk = document.getElementsByName("checkboxparam");	
			if(chk.length != null){
				for (var i=0;i<chk.length;i++) 
			    {
			        var e = chk[i];
			        if(e.checked){
						str[j]=e.value;
						i++;
					}
			    }	
			    flag = 1;		    
			}else{
				if(e.checked)
		        {
					str[j]=e.value;
					flag = 1;
			    }
			}
			if(flag==1)
		    {
		    	var curPage = document.getElementById('curPage').value;
		    	var link = document.getElementById('link').value;
		    	var toPageLink = "/admin/banner/homeSiteAdBanner.do?action=delete"+link+"&page="+curPage+"&checkboxparam="+str;
		    	window.location=encodeURI(toPageLink);
		    	return true;
			}else{
				window.alert('至少选择一项!');
			   return false;
			}
		   
		   
		}
		
//-->
</script>
		<script type="text/javascript" language="javascript">
		  //通过一级分类id,获取二级分类的列表
		  function loadSecondHomeSiteClassList()
		  {
		      var newsClassId = document.getElementById('firstNewsClassId').value;
		     if(newsClassId!=null  && newsClassId!='-1')
		     {
		       //alert('广告栏目id:'+newsClassId);
		        //获取二级列表
		        homeSiteDWRServ.loadSecondHomeSiteNewsClassByAdType(newsClassId,fillSecondList);
		        
		     }
		  }
		  
		  
		  //通过二级分类id,获取三级分类的列表
		   function loadThirdHomeSiteClassList()
		  {
		      var newsClassId = document.getElementById('secondNewsClassId').value;
		     if(newsClassId!=null  && newsClassId!='-1')
		     {
		       //alert('广告栏目id:'+newsClassId);
		        //获取二级列表
		        homeSiteDWRServ.loadSecondHomeSiteNewsClassByAdType(newsClassId,fillThirdList);
		        
		        //通过二级分类的id,加载出广告描述列表
		        getHomeSiteAdBannerDescriptionList(newsClassId);
		     }
		  }
		     
		  
		  //二级分类列表
		  var data2;
		  function fillSecondList(data2)
		  {
		    DWRUtil.removeAllOptions("secondNewsClassId");
            //DWRUtil.addOptions("secondNewsClassId", data2.id,data2.picName);
            DWRUtil.addOptions("secondNewsClassId", {'-1':'请选择'});
            DWRUtil.addOptions("secondNewsClassId", data2);
		  }
		  
		  
		  //填充三级分类列表
		  var data3;
		  function fillThirdList(data3)
		  {
		    DWRUtil.removeAllOptions("thirdNewsClassId");
            //DWRUtil.addOptions("thirdNewsClassId", data3.id,data3.picName);
            DWRUtil.addOptions("thirdNewsClassId", {'-1':'请选择'});
            DWRUtil.addOptions("thirdNewsClassId", data3);
		  }
		  
		  //通过三级分类id,加载出广告描述列表
		  function  loadAdBannerDescriptionList()
		  {
		     var newsClassId = document.getElementById('thirdNewsClassId').value;
		     if(newsClassId!=null  && newsClassId!='-1')
		     {
		       //alert('广告栏目id:'+newsClassId);
		       
		        //通过三级分类的id,加载出广告描述列表
		        getHomeSiteAdBannerDescriptionList(newsClassId);
		     }
		  }
		  
		  //通过分类id,获取广告描述列表
		  var newsClassId;
		  function getHomeSiteAdBannerDescriptionList(newsClassId)
		  {
		      homeSiteDWRServ.loadAdBannerListByHomeSiteNewsClassId(newsClassId,fillDescription);
		  }
		  
		  var data;
		  function fillDescription(data)
		  {
		    DWRUtil.removeAllOptions("hsDesId");
            //DWRUtil.addOptions("hsDesId", data.id,data.picName);
            DWRUtil.addOptions("hsDesId", {'-1':'请选择'});
            DWRUtil.addOptions("hsDesId", data);
		  }
		  
		</script>

</head>
<body>
	
	<html:form action="/admin/banner/homeSiteAdBanner.do?action=search" method="post">
			<input type="hidden" id="curPage" value="${curPage}" />
						
		<c:set var="linkStr" value="&type=1&newsClassId=${newsClassId}&title=${title}
				&hsDesId=${hsDesId}&firstId=${firstId}&secondId=${secondId}&thirdId=${thirdId}"/>
		<input type="hidden" id="link" value="${linkStr}">
		<html:hidden property="page" value="${curPage }"/>
		
						
		<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0">
			
			<tr>
				<td width="10%" bgcolor="#F6F6F6" class="STYLE1" colspan="13">
							分 类：
						&nbsp;
							<span class="STYLE1">一级分类</span>
							<html:select property="firstNewsClassId" onchange="loadSecondHomeSiteClassList();">
							   <html:option value="-1">---请选择---</html:option>
							   <logic:present name="firstHomeSiteNewsClassList">
							   		<logic:iterate id="list" name="firstHomeSiteNewsClassList">
									    <option value="${list.id}" <c:if test="${list.id==firstId}">selected</c:if>>${list.names}</option>
								    </logic:iterate>
							   		<html:optionsCollection name="firstHomeSiteNewsClassList" label="names" value="id"/>
							   </logic:present>							   
							</html:select>
						
							<span class="STYLE1">二级分类</span>
							<html:select property="secondNewsClassId" onchange="loadThirdHomeSiteClassList();">
							   <html:option value="-1">---请选择---</html:option>
							   <logic:present name="secondNewsClassList">
							   		<logic:iterate id="list" name="secondNewsClassList">
									    <option value="${list.key}" <c:if test="${list.key==secondId}">selected</c:if>>${list.value}</option>
								    </logic:iterate>
							   </logic:present>
							</html:select>
						
							<span class="STYLE1">三级分类</span>
							<html:select property="thirdNewsClassId" onchange="loadAdBannerDescriptionList();">
							   <html:option value="-1">---请选择---</html:option>
							   <logic:present name="thirdNewsClassList">
							   		<logic:iterate id="list" name="thirdNewsClassList">
									    <option value="${list.key}" <c:if test="${list.key==thirdId}">selected</c:if>>${list.value}</option>
								    </logic:iterate>
							   </logic:present>
							</html:select>
							
						</td>
						
			</tr>
			<tr>
				<td  bgcolor="#F6F6F6" class="STYLE1" colspan="13">
					广告描述：
							<html:select property="hsDesId">
									<option value="-1">---请选择---</option>
								<logic:present name="hsDesList">
							   		<logic:iterate id="list" name="hsDesList">
									    <option value="${list.id}" <c:if test="${list.id==hsDesId}">selected</c:if>>${list.picName }</option>
								    </logic:iterate>
							   		<html:optionsCollection name="hsDesList" label="picName" value="id"/>
							   </logic:present>
							</html:select>
							<font color="red">*</font>
				
					广告标题： <html:text property="title" size="15" value="${title}"></html:text>
					<html:submit value="给我搜" />&nbsp;&nbsp;<font size="4" color="red">
					<a href="/admin/banner/homeSiteAdBanner.do?action=toAdd">添 加</a></font>
				</td>
			</tr>
			
			
			<tr>
				<td  bgcolor="#FEDFC0">
					<div align="center" class="STYLE1">
						※
					</div>
				</td>
				<td height="26" bgcolor="#FEDFC0">
					<div align="center" class="STYLE1">
						广告ID
					</div>
				</td>
				<td height="26" bgcolor="#FEDFC0">
					<div align="center" class="STYLE1">
						排序值
					</div>
				</td>
				<td bgcolor="#FEDFC0">
					<div align="center" class="STYLE1">
						栏 目
					</div>
				</td>
				<td bgcolor="#FEDFC0">
					<div align="center" class="STYLE1">
						标 题
					</div>
				</td>
				<td bgcolor="#FEDFC0">
					<div align="center" class="STYLE1">
						是否图片
					</div>
				</td>
				<td bgcolor="#FEDFC0">
					<div align="center" class="STYLE1">
						是否启用外部链接
					</div>
				</td>
				<td bgcolor="#FEDFC0">
					<div align="center" class="STYLE1">
						是否JS广告
					</div>
				</td>
				<td colspan="2" bgcolor="#FEDFC0">
					<div align="center" class="STYLE1">
						排 序
					</div>
				</td>
				<td bgcolor="#FEDFC0">
					<div align="center" class="STYLE1">
						<div align="center">
							操 作
						</div>
					</div>
				</td>
			</tr>
				<logic:notEmpty name="bannerList">
					<logic:iterate id="list" name="bannerList">
						<input type="hidden" name="id" value="${list.id}" />

						<tr align="center">
							<td>
								<input type="checkbox" name="checkboxparam" value="${list.id}">
							</td>

							<td>
								<b>${list.id}</b>
							</td>
							
							<td>
								<font color="red"><b>${list.sequence}</b></font>
							</td>
							
							<td>
								${list.className}
							</td>

							<td>
								${fn:substring(list.title,0,10)}
							</td>

							<td class="STYLE1">
								${list.isImg!=0?'★':'☆'}

							</td>

							<td class="STYLE1">
								${list.isLink!=0?'★':'☆'}

							</td>

							<td class="STYLE1">
								${list.isJs!=0?'★':'☆'}
							</td>

							<td  bgcolor="#F6F6F6" class="STYLE1">
								<div align="center">
									<a href="/admin/banner/homeSiteAdBanner.do?action=move&id=${list.id}&moveType=0${linkStr}&page=${curPage}">
									<img src="../images/tu_s.gif" width="14" height="14" /></a>
								</div>
							</td>
							<td bgcolor="#F6F6F6" class="STYLE1">
								<div align="center">
									<a href="/admin/banner/homeSiteAdBanner.do?action=move&id=${list.id}&moveType=1${linkStr}&page=${curPage}">
									<img src="../images/tu_x.gif" width="14" height="14" /></a>
								</div>
							</td>

							<td>
								<c:set var="paraement" value="${linkStr}"></c:set>
								<a href="/admin/banner/homeSiteAdBanner.do?action=toUpdate${linkStr}&page=${curPage}&id=${list.id}">
									<img src="/admin/images/edititem.gif"/></a>
								<%--<a href="/admin/banner/homeSiteAdBanner.do?action=toUpdate&id=${list.id}">
									<img src="/admin/images/edititem.gif"/></a>--%>
							</td>
						</tr>
					</logic:iterate>
				</logic:notEmpty>


			<tr>
				<td colspan="13">
					<input type="button" onclick="selectAll(1);" value="全选" />
					&nbsp;
					<input type="button" onclick="selectAll(2);" value="反选" />
					&nbsp;
					<input type="button" onclick="selectAll(3);" value="不选" />
					&nbsp;
					<input type="button" value="选择删除"  onclick="return checkboxIsSelected();">
					<font color="red">注：&nbsp;★ 为是， ☆ 为否 ，排序慎用：排序值是同一位置下的广告的排序</font>
				</td>
			</tr>
			
			
		<logic:notEmpty name="bannerList">
		<tr>
			<td colspan="13">			
		
			
			&nbsp;&nbsp;&nbsp;共有 <b>${recordNum}</b> 条记录，当前
			<span class="red1"><font color="red">${curPage}</font>/${allPage}</span> 页 &nbsp;&nbsp;|&nbsp;&nbsp;
			<%--  首页  --%>
			<a href="/admin/banner/homeSiteAdBanner.do?action=search${linkStr}">首页</a>
			<%--  上一页  --%>
			<a href="/admin/banner/homeSiteAdBanner.do?action=search${linkStr}&page=${backPage}">上一页</a>

			<%--  页码循环 --%>
			<c:forEach begin="${1}" end="${allPage}" var="page"
				varStatus="pageCount">
				<a href="/admin/banner/homeSiteAdBanner.do?action=search${linkStr}&page=${page}">

					<c:if test="${curPage==page}">
						<font color="red" class="one"><c:out
								value="${pageCount.index}"></c:out>
						</font>
					</c:if>
					<c:if test="${curPage!=page}">
						<c:out value="${pageCount.index}"></c:out>
					</c:if>

				</a>
			</c:forEach>

			<%--  下一页  --%>
			<a href="/admin/banner/homeSiteAdBanner.do?action=search${linkStr}&page=${nextPage}">下一页</a>
			<%--  尾页  --%>
			<a href="/admin/banner/homeSiteAdBanner.do?action=search${linkStr}&page=${allPage}">尾页</a>
			到 <input id="toPageId" name="toPage" type="text" class="input100" size="4" maxlength="4" />
			页&nbsp;
			<input type="button" value=" "
				style="background-image: url('../images/ck.gif');border:0px;width:58px;"
				title="查看" onclick="return topage();" />
				
			</td>
		</tr>
		
		</logic:notEmpty>
			
			
		</table>
	</html:form>

	
	<logic:present name="msg">
		<bean:write name="msg" filter="false" />
	</logic:present>
</body>
</html:html>
